﻿#pragma once

#include "../../Shared/Data/ItemData.h"
#include "../../Server/MirEnvir/Envir.h"
#include <string>
#include <unordered_map>
#include <vector>
#include <any>

using namespace Server::MirEnvir;

namespace Server
{
    class GameShop : public System::Windows::Forms::Form
    {

    private:
        std::vector<GameShopItem*> SelectedItems;

    public:
        virtual ~GameShop()
        {
            delete components;
            delete GameShopListBox;
            delete label14;
            delete GoldPrice_textbox;
            delete label21;
            delete GPPrice_textbox;
            delete label29;
            delete ItemDetails_gb;
            delete Class_combo;
            delete label4;
            delete groupBox3;
            delete DealofDay_checkbox;
            delete TopItem_checkbox;
            delete Remove_button;
            delete Category_textbox;
            delete label1;
            delete Individual_checkbox;
            delete Stock_textbox;
            delete label2;
            delete CredxGold_textbox;
            delete TotalSold_label;
            delete label5;
            delete LeftinStock_label;
            delete label3;
            delete label6;
            delete Count_textbox;
            delete ClassFilter_lb;
            delete SectionFilter_lb;
            delete CategoryFilter_lb;
            delete ResetFilter_button;
            delete ServerLog_button;
        }

        Server::MirEnvir::Envir *getEnvir() const;

        GameShop();

    private:
        void GameShop_Load(std::any sender, EventArgs *e);

        void GameShop_FormClosed(std::any sender, FormClosedEventArgs *e);

    public:
        class ListBoxItem
        {
        private:
            std::string DisplayMember;
            std::any ValueMember;

        public:
            std::string getDisplayMember() const;
            void setDisplayMember(const std::string &value);
            std::any getValueMember() const;
            void setValueMember(const std::any &value);

            std::string ToString();
        };

    private:
        void LoadGameShopItems();

        void UpdateGameShopList();

        void GameShopListBox_SelectedIndexChanged(std::any sender, EventArgs *e);

    public:
        void UpdateInterface(bool refreshList = false);

    private:
        void GetStats();

        void GoldPrice_textbox_TextChanged(std::any sender, EventArgs *e);

        void GPPrice_textbox_TextChanged(std::any sender, EventArgs *e);

        void Class_combo_SelectedIndexChanged(std::any sender, EventArgs *e);

        void TopItem_checkbox_CheckedChanged(std::any sender, EventArgs *e);

        void Remove_button_Click(std::any sender, EventArgs *e);

        void DealofDay_checkbox_CheckedChanged(std::any sender, EventArgs *e);

        void Category_textbox_TextChanged(std::any sender, EventArgs *e);

        void Stock_textbox_TextChanged(std::any sender, EventArgs *e);

        void Individual_checkbox_CheckedChanged(std::any sender, EventArgs *e);

        void CredxGold_textbox_TextChanged(std::any sender, EventArgs *e);

        void Count_textbox_TextChanged(std::any sender, EventArgs *e);

        void ClassFilter_lb_SelectedIndexChanged(std::any sender, EventArgs *e);

        void SectionFilter_lb_SelectedIndexChanged(std::any sender, EventArgs *e);

        void CategoryFilter_lb_SelectedIndexChanged(std::any sender, EventArgs *e);

        void ResetFilter_button_Click(std::any sender, EventArgs *e);

        void ServerLog_button_Click(std::any sender, EventArgs *e);


        /// <summary>
        /// Required designer variable.
        /// </summary>
        System::ComponentModel::IContainer *components = nullptr;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
    protected:
        void Dispose(bool disposing) override;

        #pragma region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
    private:
        void InitializeComponent();

        #pragma endregion

        System::Windows::Forms::ListBox *GameShopListBox;
        System::Windows::Forms::Label *label14;
        System::Windows::Forms::TextBox *GoldPrice_textbox;
        System::Windows::Forms::Label *label21;
        System::Windows::Forms::TextBox *GPPrice_textbox;
        System::Windows::Forms::Label *label29;
        System::Windows::Forms::GroupBox *ItemDetails_gb;
        System::Windows::Forms::ComboBox *Class_combo;
        System::Windows::Forms::Label *label4;
        System::Windows::Forms::GroupBox *groupBox3;
        System::Windows::Forms::CheckBox *DealofDay_checkbox;
        System::Windows::Forms::CheckBox *TopItem_checkbox;
        System::Windows::Forms::Button *Remove_button;
        System::Windows::Forms::TextBox *Category_textbox;
        System::Windows::Forms::Label *label1;
        System::Windows::Forms::CheckBox *Individual_checkbox;
        System::Windows::Forms::TextBox *Stock_textbox;
        System::Windows::Forms::Label *label2;
        System::Windows::Forms::TextBox *CredxGold_textbox;
        System::Windows::Forms::Label *TotalSold_label;
        System::Windows::Forms::Label *label5;
        System::Windows::Forms::Label *LeftinStock_label;
        System::Windows::Forms::Label *label3;
        System::Windows::Forms::Label *label6;
        System::Windows::Forms::TextBox *Count_textbox;
        System::Windows::Forms::ComboBox *ClassFilter_lb;
        System::Windows::Forms::ComboBox *SectionFilter_lb;
        System::Windows::Forms::ComboBox *CategoryFilter_lb;
        System::Windows::Forms::Button *ResetFilter_button;
        System::Windows::Forms::Button *ServerLog_button;
    };
}
